package com.example.demo.study.studentmanagement2;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
//        StudentManager studentManager = new StudentManager();

        // 单例模式 -- 创建对象
       StudentManagerNew studentManagerNew = StudentManagerNew.getInstance();

        Boolean flag = true;

        System.out.println("\n===== 学生信息管理系统 =====");
        System.out.println("1. 添加学生\t2. 删除学生\t3. 修改学生信息\4. 查询所有学生\t5. 根据学号查询学生\t6. 退出系统");

        do{
            System.out.print("请输入你的选择：");
            int choice = scanner.nextInt();
            switch (choice){
                case 1:
                    System.out.print("请输入学号：");
                    String id = scanner.next();
                    System.out.print("请输入姓名：");
                    String name = scanner.next();
                    System.out.print("请输入年龄：");
                    int age = scanner.nextInt();
                    System.out.print("请输入班级：");
                    String className = scanner.next();
                    studentManagerNew.addStudent(new Stundent(id,name,age,className));
                    break;
                case 2:
                    System.out.print("请输入要删除的学生学号：");
                    studentManagerNew.deleteStudent(scanner.next());
                    break;
                case 3:
                    try {
                        System.out.print("请输入要修改的学生学号：");
                        String updateId = scanner.next();
                        System.out.print("请输入新姓名（不修改请直接回车）：");
                        String newName = scanner.next();
                        System.out.print("请输入新年龄（不修改请输入0）：");
                        int newAge = scanner.nextInt();
                        System.out.print("请输入新班级（不修改请直接回车）：");
                        String newClass = scanner.next();
                        studentManagerNew.updateStudent(new Stundent(updateId,newName,newAge,newClass));
                    }catch (Exception e){
                        System.out.println(e.getMessage());
                    }

                    break;
                case 4:
                    studentManagerNew.queryStudent();
                    break;
                case 5:
                    System.out.print("请输入要查询的学生学号：");
                    studentManagerNew.findStudentById(scanner.next());
                    break;
                case 6:
                    flag = false;
                    System.out.print("退出系统：");
                    break;
            }
        }while (flag);







    }
}
